<template>
  <div class="MatchSignUp">
    <div class="basicInfo">
      <div style="flex: 1.5;">
        <span>
          赛事名称：
          <b>{{ MatchSign.name }}</b>
        </span>
        <span>
          裁判长：
          <b>{{ MatchSign.get_ref ? MatchSign.get_ref.get_user.name : '' }}</b>
        </span>
      </div>
      <div style="flex: 2;display: flex;justify-content: flex-end;align-items: baseline;">
        <div class="btnGroup" style="display: flex;">
          <el-upload class="upload-demo" action="string" :show-file-list="false" :http-request="uploadExcel">
            <el-button type="danger" size="small" v-loading="Imploading">导入报名信息</el-button>
          </el-upload>
          <el-upload class="upload-demo" action="string" :show-file-list="false" :http-request="team_uploadExcel">
            <el-button type="danger" size="small" style="margin-left: 10px;" v-loading="team_Imploading">导入团体报名信息</el-button>
          </el-upload>
          <a style="margin-left: 10px;" :href="ApplyUrl" download="报名信息">
            <el-button type="primary" size="small" @click="opens" v-loading="loading">导出报名信息</el-button>
          </a>
          <a style="margin-left: 10px;" :href="SignUrl" download="签到信息">
            <el-button type="primary" size="small">导出签到信息</el-button>
          </a>
        </div>
      </div>
    </div>
    <div class="Content" style="margin-top: 20px">
      <div class="ContentSelect">
        <div class="Team">
          <div>组别：</div>
          <el-select v-model="TeamsSelect" size="small" style="width: 60%;">
            <el-option v-for="team in MatchSign.get_project" :key="team.id" :label="team.teamname" :value="team.id"></el-option>
          </el-select>
        </div>
        <div v-if="!showLimitInputs" class="Team">
          <div>省份：</div>
          <el-cascader size="small" :options="searchProvinceOptions" v-model="searchProvinceSelect" @change="provinceSearch"
            style="width: 60%;"></el-cascader>
        </div>
        <div v-if="showLimitInputs" class="Team">
          <div>自定义：</div>
          <el-input size="small" placeholder="请输入自定义条件" v-model="SearchSelfDefinedInput" style="width: 60%"></el-input>
        </div>
        <div class="Team">
          <div>关键字：</div>
          <el-input size="small" placeholder="请输入名字/电话号码" v-model="SearchInput" style="width: 60%"></el-input>
        </div>
        <!--<el-button type="primary" round size="medium" @click="search">搜索</el-button>-->
      </div>
      <div style="display: flex;align-items: baseline;padding-left: 7%;margin-top: 30px;">
        <el-button @click="toggleSelection">一键签到</el-button>
        <div style="margin-left: 10px;">
          <b>签到人数：{{ signCount }}/{{ count }}人</b>
        </div>
      </div>
      <el-table ref="multipleTable" :data="MatchSignUpList" tooltip-effect="dark" stripe height="700" v-loading="loadingTable"
        :default-sort="{ prop: 'ids', order: 'ascending' }" style="margin-top: 30px;padding-left: 7%;" v-if="MatchSignUpList">
        <el-table-column label="签到" width="80">
          <template slot-scope="scope">
            <el-switch v-model="scope.row.radio" :disabled="scope.row.check_status == 1" active-color="#409EFF" @change="cancelSign(scope.$index, scope.row, scope.row.radio)"></el-switch>
          </template>
        </el-table-column>
        <el-table-column v-if="MatchSignUpList[0].team_name == null" prop="ids" label="序号" width="50"></el-table-column>
        <el-table-column v-if="MatchSignUpList[0].team_name != null" prop="team_name" label="团体名称" width="120"></el-table-column>
        <el-table-column prop="name" label="姓名" width="120"></el-table-column>
        <el-table-column prop="age" label="年龄" width="50"></el-table-column>
        <el-table-column prop="sexs" label="性别" width="50"></el-table-column>
        <el-table-column prop="card" label="身份证号" width="170"></el-table-column>
        <el-table-column prop="project" label="项目组别" width="80"></el-table-column>
        <el-table-column prop="phone" label="手机号" width="120"></el-table-column>
        <!-- 新增一列订单号 -->
        <el-table-column prop="order_num" label="订单号" width="140"></el-table-column>

        <el-table-column prop="one_limits" v-if="MatchSignUpList[0].one_limitsName" :label="MatchSignUpList[0].one_limitsName"
          sortable width="100"></el-table-column>
        <el-table-column prop="two_limits" v-if="MatchSignUpList[0].two_limitsName" :label="MatchSignUpList[0].two_limitsName"
          sortable width="100"></el-table-column>
        <el-table-column prop="three_limits" v-if="MatchSignUpList[0].three_limitsName" :label="MatchSignUpList[0].three_limitsName"
          sortable width="100"></el-table-column>
        <el-table-column prop="fure_limits" v-if="MatchSignUpList[0].fure_limitsName" :label="MatchSignUpList[0].fure_limitsName"
          sortable width="70"></el-table-column>
        <el-table-column prop="sign_base_name" label="报名人" width="120"></el-table-column>
        <el-table-column label="操作" width="220">
          <template slot-scope="scope">
            <el-button size="mini" type="primary" plain @click="handleEdit(scope.$index, scope.row)" v-if="scope.row.check_status != 1">修改</el-button>
            <el-button size="mini" type="danger" plain @click="handleDelete(scope.$index, scope.row)" v-if="scope.row.check_status != 1">删除</el-button>
            <el-button size="mini" type="warning" plain @click="handleRefund(scope.$index, scope.row)" v-if="refund(scope.row)">退款</el-button>
            <span v-if="scope.row.check_status == 1">已抽签</span>
          </template>
        </el-table-column>
      </el-table>
      <!-- 修改报名信息对话框 -->
      <el-dialog title="修改报名信息" :visible.sync="ShowChange" width="450px">
        <div class="Team" style="margin-bottom: 30px;">
          <div class="TeamName">姓名：</div>
          <el-input style="width: 200px;" size="small" v-model="ModelChange.name" clearable></el-input>
        </div>
        <div class="Team" style="margin-bottom: 30px;">
          <div class="TeamName">项目-组别：</div>
          <el-select v-model="ModelChange.project" placeholder="请选择" size="small" style="width: 200px;">
            <el-option v-for="team in MatchSign.get_project" :key="team.id" :label="team.teamname" :value="team.teamname"></el-option>
          </el-select>
        </div>
        <div class="Team" style="margin-bottom: 30px;" v-if="isTeam">
          <div class="TeamName">团体名称：</div>
          <el-input style="width: 200px;" size="small" v-model="ModelChange.team_name" clearable></el-input>
        </div>
        <div v-if="projectName.length != 0" class="Team" style="margin-bottom: 30px;" v-for="(item, index) in ModelChange.customize">
          <div class="TeamName">{{ projectName[index] ? projectName[index].label : '' }}：</div>
          <el-input size="small" placeholder="请输入自定义条件" v-model="ModelChange.customize[index]" style="width: 200px;"></el-input>
        </div>
        <div class="Team" style="margin-bottom: 30px;">
          <div class="TeamName">身份证号码：</div>
          <el-input style="width: 200px;" size="small" maxlength="18" v-model="ModelChange.card" clearable></el-input>
        </div>
        <div class="Team">
          <div class="TeamName">手机号码：</div>
          <el-input style="width: 200px;" size="small" maxlength="11" v-model="ModelChange.phone" clearable></el-input>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button @click="ShowChange = false">取 消</el-button>
          <el-button type="primary" @click="ConfirmChange">确 定</el-button>
        </div>
      </el-dialog>
    </div>
    <div style="justify-content: center;display: flex;margin-top: 50px;margin-bottom: 100px;">
      <el-button round style="width: 150px;margin-right: 50px;" type="primary" @click="ConfirmSign">确定签到</el-button>
			<el-button round style="width: 150px;margin-right: 50px;" type="primary" @click="randomSign">随机签到</el-button>
      <el-button round style="width: 150px;margin-right: 50px;" type="primary" v-if="MatchStatus.com_status == 1"
        @click="skipLayout">编排</el-button>
      <el-button round style="width: 150px;" type="primary" plain @click="Back">返回</el-button>
    </div>
  </div>
</template>
<script>
  import {
    mapState
  } from 'vuex';
  import {
    provinceAndCityData,
    regionData,
    provinceAndCityDataPlus,
    regionDataPlus,
    CodeToText,
    TextToCode
  } from 'element-china-area-data';
  export default {
    name: 'MatchSignUp',
		inject:["reload"],
    data() {
      return {
        updataProject: '',
        loading: false,
        Imploading: false,
        team_Imploading: false,
        ShowChange: false,
        ModelChange: {},
        ModelChangeID: '',
        isTeam:false,
        ChangeTeam: '',
        ChangeProvince: '',
        options3: CodeToText,
        //搜索
        searchProvinceOptions: [],
        searchProvinceSelect: [],
        searchProvinceSelectText: [],
        showLimitInputs: true,
        SearchSelfDefinedInput: '',
        SearchInput: '',
        TeamsSelect: '',
        //修改
        changeProvinceOptions: [],
        changeProvinceSelect: [],
        changeProvinceSelectText: [],
        showchangeLimitInputs: false,
        ChangeSelfDefinedInput: [],
        //导入excel
        excelList: [],
        UploadFile: {},
        PagesAll: 0,
        showMatchList: [],
        currentPage: 1,
        getprojectProp: [],
        // 一键签到
        buttonSign: false,
        OnwbuttonSign: [],
        TwobuttonSign: [],
        // 修改自定义的组别
        OneChangeSelfDefinedInput: '',
        TwoChangeSelfDefinedInput: '',
        ThreeChangeSelfDefinedInput: '',
        setStatus: false,
        // MatchSignUpTable:this.MatchSignUpTable,
        // 获取项目组别id
        projectId: [],
        valueProjectId: '',
        signCount: 0,
        isSignHide: true,
        count: 0,
        matchCount: {},
        loadingTable: true
      };
    },
    created() {

    },
    mounted() {
      this.loadingTable = true;
      let idObj = {};
      idObj.com_id = this.$route.query.MatchId;
      idObj.project_id = this.$route.query.teamId;
      this.$store.dispatch('getMatchApplySignChange', idObj).then(() => {
        this.updataProject = idObj.project_id;
        this.TeamsSelect = this.MatchStatus.project_id //默认选中组别
        for (let a in this.MatchSignUpTable) {
          this.$set(this.MatchSignUpTable[a], 'radio', false);
          if (this.MatchSignUpTable[a].status == 1) {
            this.$set(this.MatchSignUpTable[a], 'radio', true);
          }
        }
        this.loadingTable = false;
      });
    },
    watch: {
      MatchStatus(val) {
        this.count = val.count;
        this.signCount = val.sign_count;
      },
      'ModelChange.project'(val) {
        this.updataProject = val;
      },
      MatchSign: function(val) {
        this.projectId = val.get_project;
        for (let i in val.get_project) {
          val.get_project[i].teamname = val.get_project[i].group + val.get_project[i].type;
        }
      },
      //监听搜索
      TeamsSelect: function() {
        this.search();
      },
      searchProvinceSelect() {
        this.search();
      },
      SearchSelfDefinedInput() {
        this.search();
      },
      SearchInput() {
        this.search();
      }
    },
    computed: {
      ...mapState({
        MatchSign: 'MatchSign',
        MatchSignUpTable: 'MatchSignUpTable',
        projectName: 'projectName',
        MatchStatus: 'MatchStatus',
        MatchSignUpLists: 'MatchSignUpLists'
      }),
      ApplyUrl() {
        let project_id = this.TeamsSelect ? '&project_id=' + this.TeamsSelect : '';
        let url = this.$axios.defaults.baseURL + '/event/export_sign?com_id=' + this.$route.query.MatchId + project_id;
        return url;
      },
      SignUrl() {
        let project_id = this.TeamsSelect ? '&project_id=' + this.TeamsSelect : '';
        let url = this.$axios.defaults.baseURL + '/event/export_sign?com_id=' + this.$route.query.MatchId + '&status=1' +
          project_id;
        return url;
      },
      MatchSignUpList() {
        let List = [];
        List = this.MatchSignUpTable
        if (!List){
          return
        }
        // this.TeamsSelect = parseInt(this.$route.query.teamId) || this.MatchSign.get_project[0].id
        // List = this.MatchSignUpLists
        if (List.length == 0) {
          //初始化 避免undefined报错
          return (List = [{
            one_limitsName: '0',
            two_limitsName: '1',
            three_limitsName: '2',
            fure_limitsName: '3'
          }]);
        }
        if (this.projectName.length == 0) {
          this.loadingTable = false;
          return List;
        } //没有限制条件时
        for (let player in List) {
          if ((List[player].customize[0] && this.projectName.length > 0) || List[player].customize[0] == 0) {
            if (!isNaN(parseInt(List[player].customize[0]))) {
              List[player].customize[0] = List[player].customize[0];
            }
            List[player].one_limits = List[player].customize[0];
            List[player].one_limitsName = this.projectName[0].label;
          }
          if ((List[player].customize[1] && this.projectName.length > 1) || List[player].customize[1] == 0) {
            if (!isNaN(parseInt(List[player].customize[1]))) {
              List[player].customize[1] = List[player].customize[1];
            }
            List[player].two_limits = List[player].customize[1];
            List[player].two_limitsName = this.projectName[1].label;
          }
          if ((List[player].customize[2] && this.projectName.length > 2) || List[player].customize[2] == 0) {
            if (!isNaN(parseInt(List[player].customize[2]))) {
              List[player].customize[2] = List[player].customize[2];
            }
            List[player].three_limits = List[player].customize[2];
            List[player].three_limitsName = this.projectName[2].label;
          }
          if ((List[player].customize[3] && this.projectName.length > 3) || List[player].customize[3] == 0) {
            if (!isNaN(parseInt(List[player].customize[3]))) {
              List[player].customize[3] = parseInt(List[player].customize[3]);
            }
            List[player].fure_limits = List[player].customize[3];
            List[player].fure_limitsName = this.projectName[3].label;
          }
        }
        this.loadingTable = false;
        return List;
      },
      refund(item) {
        return (item) => {
          return item.order_num && sessionStorage.getItem('user_type') == 5 && item.check_status != 1 ? true : false
        };
      }
    },
    methods: {
      // 取消签到
      cancelSign(index, item, status) {
        if (!status) {
          this.$confirm('确定取消签到?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
              // center: true
            })
            .then(() => {
              this.$axios
                .post(
                  '/event/cancel_the_check', {
                    id: item.id
                  }, {
                    headers: {
                      token: window.sessionStorage.getItem('token')
                    }
                  }
                )
                .then(res => {
                  if (res.data.code == 2000) {
                    this.$message({
                      message: res.data.msg,
                      type: 'success'
                    });
                  } else {
                    this.$message({
                      message: res.data.msg,
                      type: 'error'
                    });
                  }
                });
            })
            .catch(() => {
              this.$set(this.MatchSignUpTable[index], 'radio', true);
              this.$message({
                type: 'info',
                message: '您已取消'
              });
            });
        }
      },
      opens() {
        this.loading = true;
        setTimeout(() => {
          this.loading = false;
        }, 800);
      },
      skipLayout() {
        if (this.$store.state.MatchStatus.com_status === 1) {
          this.$router.push({
            path: '/index/match/LayoutDraw',
            query: {
              MatchId: this.$route.query.MatchId
            }
          });
        } else {
          this.$router.push({
            path: '/index/match/Layout',
            query: {
              MatchId: this.$route.query.MatchId
            }
          });
        }
      },
      switchHandClick(index, rows) {
        if (this.MatchSignUpTable[index].status == 1) {
          this.MatchSignUpTable[index].status = 0;
        } else {
          this.MatchSignUpTable[index].status = 1;
        }
      },
      toggleSelection() {
        for (let i in this.MatchSignUpTable) {
          this.$set(this.MatchSignUpTable[i], 'radio', true);
          this.$set(this.MatchSignUpTable[i], 'status', true);
        }
      },
      handleChange(file, fileList) {
        this.PdfList = fileList.slice(-3);
      },
      fileUploadSuccess(response, file, fileList) {
        this.fileUrl = response.data;
      },
      beforeAvatarUpload(file) {
        let a = file.name;
        const isExcel = a.substring(a.length - 4) == '.xls';
        const isExcel20M = file.size / 1024 / 1024 < 20;
        if (!isExcel) {
          this.$message.error('上传竞赛规程只能是 xls 格式!');
          file.slice(1);
        }
        this.UploadFile = file;
        return isExcel;
      },
      uploadExcel(item) {
        this.Imploading = true;
        let formData = new FormData();
        formData.append('sign_excel_file', item.file);
        formData.append('com_id', this.$route.query.MatchId);
        this.$axios
          .post('/Competition/import_sign_info', formData, {
            headers: {
              token: window.sessionStorage.getItem('token')
            }
          })
          .then(res => {
            this.Imploading = false;
            let idObj = {};
            idObj.com_id = this.$route.query.MatchId;
            idObj.project_id = this.$route.query.teamId;
            this.$store.dispatch('getMatchApplySignChange', idObj);
            if (res.data.code == 200) {
              this.$message({
                type: 'success',
                message: res.data.message
              });
            } else {
              this.$message({
                type: 'error',
                message: res.data.message
              });
            }
          });
      },
      team_uploadExcel(item) {
        this.team_Imploading = true;
        let formData = new FormData();
        formData.append('sign_excel_file', item.file);
        formData.append('com_id', this.$route.query.MatchId);
        this.$axios
          .post('/Competition/export_team', formData, {
            headers: {
              token: window.sessionStorage.getItem('token')
            }
          })
          .then(res => {
            this.team_Imploading = false;
            let idObj = {};
            idObj.com_id = this.$route.query.MatchId;
            idObj.project_id = this.$route.query.teamId;
            this.$store.dispatch('getMatchApplySignChange', idObj);
            if (res.data.code == 200) {
              this.$message({
                type: 'success',
                message: res.data.message
              });
            } else {
              this.$message({
                type: 'error',
                message: res.data.message
              });
            }
          });
      },
      provinceSearch(value) {
        for (let a in this.searchProvinceSelect) {
          this.searchProvinceSelectText[a] = CodeToText[this.searchProvinceSelect[a]];
        }
      },
      provinceChange(value) {
        for (let a in this.changeProvinceSelect) {
          this.changeProvinceSelectText[a] = CodeToText[this.changeProvinceSelect[a]];
        }
      },
      search: function() {
        let searchObj = {};
        searchObj.com_id = this.$route.query.MatchId;
        searchObj.project_id = this.TeamsSelect;
        searchObj.keyword = this.SearchInput;
        let a = '';
        if (!this.showLimitInputs) {
          for (let i in this.searchProvinceSelectText) {
            a += ',' + this.searchProvinceSelectText[i];
          }
          a = a.substring(1);
        } else {
          a = this.SearchSelfDefinedInput;
        }
        searchObj.customize = a;
        this.$axios
          .post(
            '/event/check_sign', {
              com_id: searchObj.com_id,
              project_id: searchObj.project_id,
              keyword: searchObj.keyword,
              customize: searchObj.customize
            }, {
              headers: {
                token: window.sessionStorage.getItem('token')
              }
            }
          )
          .then(res => {
            this.count = res.data.data.count;
            this.signCount = res.data.data.sign_count;
            let list = res.data.data.list;
            for (let item in list) {
              list[item].radio = false;
              if (list[item].status == 1) {
                list[item].radio = true;
              }
            }
            this.$store.commit('setMatchSignUpTable', list);
          });
      },
      handleEdit: function(index, item) {
        this.updataProject = item.project_id;
        if (item.customize[1] == undefined) {}
        this.ShowChange = true;
        this.ModelChange = JSON.parse(JSON.stringify(item));
        this.ModelChangeID = index;
        this.$axios
          .post(
            '/event/sign_search', {
              com_id: item.com_id
            }, {
              headers: {
                token: window.sessionStorage.getItem('token')
              }
            }
          )
          .then(res => {
            let obj = res.data.data;
            let arr = [];
            if(this.ModelChange.project.indexOf('团')>-1){
              this.isTeam = true
            }else{
              this.isTeam = false
            }
            if (obj.one_limit) {
              arr.push(obj.one_limit);
            }
            if (obj.two_limit) {
              arr.push(obj.two_limit);
            }
            if (obj.three_limit) {
              arr.push(obj.three_limit);
            }
            this.showchangeLimitInputs = true;
          });
      },
      //新增删除
      handleDelete(index, item) {
        let msg = sessionStorage.getItem('user_type') == 5 ? '前先退款' : '请联系管理员退款';
        if (item.order_num) {
          this.$message({
            message: msg,
            type: 'info'
          });
          return
        }
        this.$confirm('确定删除此报名信息?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          })
          .then(() => {
            this.$axios
              .post(
                '/event/del_the_player', {
                  id: item.id
                }, {
                  headers: {
                    token: window.sessionStorage.getItem('token')
                  }
                }
              )
              .then(res => {
                if (res.data.code == 2000) {
                  this.MatchSignUpTable.splice(index, 1);
                  this.$message({
                    message: res.data.msg,
                    type: 'success'
                  });
                } else {
                  this.$message({
                    message: res.data.msg,
                    type: 'error'
                  });
                }
              });
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '您已取消'
            });
          });
      },
      //新增退款
      handleRefund(index, item) {
        this.$confirm('您执行了退款操作, 是否继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          })
          .then(() => {
            this.$axios
              .post(
                '/Orderpay/wx_refund', {
                  order_num: item.order_num
                }, {
                  headers: {
                    token: window.sessionStorage.getItem('token')
                  }
                }
              )
              .then(res => {
                if (res.data.code == 2000) {
                  this.$axios
                    .post(
                      '/event/check_sign', {
                        com_id: this.$route.query.MatchId,
                        project_id: this.TeamsSelect,
                        customize: '',
                        keyword: ''
                      }, {
                        headers: {
                          token: window.sessionStorage.getItem('token')
                        }
                      }
                    )
                    .then(res => {
                      this.$store.commit('setMatchSignUpTable', res.data.data.list);
                    });
                  this.$message({
                    type: 'success',
                    message: '退款成功!'
                  });
                } else {
                  this.$message({
                    message: res.data.msg,
                    type: 'error'
                  });
                }
              });
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消退款操作'
            });
          });
      },
      ConfirmChange: function() {
        if (!this.ModelChange.name.trim() || !this.ModelChange.card.trim() || !this.ModelChange.phone.trim()) {
          this.$message({
            message: '请勿输入空的字段！',
            type: 'info'
          });
          return;
        }
        if (this.ModelChange.customize[0] != '') {
          for (let i = 0; i < this.ModelChange.customize.length; i++) {
            if (this.ModelChange.customize[i] == '') {
              this.$message({
                message: '请勿输入空的字段！',
                type: 'info'
              });
              return;
            }
          }
        }
        for (let i in this.MatchSign.get_project) {
          if (this.updataProject == this.MatchSign.get_project[i].teamname) {
            this.updataProject = this.MatchSign.get_project[i].id;
          }
        }
        let project_id = this.TeamsSelect;
        let customizeArr = this.ModelChange.customize ? JSON.parse(JSON.stringify(this.ModelChange.customize)).join() : '';
        this.ChangeSelfDefinedInput.push(this.OneChangeSelfDefinedInput, this.TwoChangeSelfDefinedInput, this.ThreeChangeSelfDefinedInput);
        this.$axios
          .post(
            '/event/sign_edit', {
              id: this.ModelChange.id,
              name: this.ModelChange.name,
              card: this.ModelChange.card,
              phone: this.ModelChange.phone,
              customize: customizeArr,
              project_id: this.updataProject,
              team_name:this.ModelChange.team_name,
              user_id:this.ModelChange.user_id
            }, {
              headers: {
                token: window.sessionStorage.getItem('token')
              }
            }
          )
          .then(res => {
            if (res.data.code == 200) {
              this.$message({
                message: res.data.message,
                type: 'success'
              });
              this.$axios
                .post(
                  '/event/check_sign', {
                    com_id: this.$route.query.MatchId,
                    project_id: project_id,
                    customize: '',
                    keyword: ''
                  }, {
                    headers: {
                      token: window.sessionStorage.getItem('token')
                    }
                  }
                )
                .then(res => {
                  console.log(res)
                  this.$store.commit('setMatchSignUpTable', res.data.data.list);
                });
            } else {
              this.$message({
                message: res.data.message,
                type: 'error'
              });
            }
            this.ShowChange = false;
          });
      },
			// 随机签到
			randomSign(){
				console.log(this.TeamsSelect)
				this.$axios.post('ComInfo/sign_select',{project_id:this.TeamsSelect},{headers:{token:window.sessionStorage.getItem('token')}})
				.then(res=>{
					console.log(res)
					if(res.data.code==2000){
						this.$message({
							message:res.data.msg,
							type: 'success'
						});
						this.reload()
					}else{
						this.$message({
							message:res.data.msg,
							type: 'warning'
						});
					}
				})
			},
			
			ConfirmSign: function() {
        //给查看签到渲染用的
        let checkSignUpObj = {};
        let teams = '';
        checkSignUpObj.MatchSignUpTable = this.MatchSignUpTable;
        checkSignUpObj.searchProvinceSelect = this.searchProvinceSelect;
        checkSignUpObj.SearchSelfDefinedInput = this.SearchSelfDefinedInput;
        checkSignUpObj.SearchInput = this.SearchInput;
        checkSignUpObj.showLimitInputs = this.showLimitInputs;
        let projects = this.MatchSign.get_project;
        for (let i in projects) {
          if (projects[i].id == this.TeamsSelect) {
            teams = projects[i].teamname;
          }
        }
        checkSignUpObj.teamsSelect = teams;
        this.$store.commit('setCheckMatchSignUp', checkSignUpObj);
        let signArr = [];
        for (let i in this.MatchSignUpTable) {
          if (this.MatchSignUpTable[i].radio) {
            signArr.push(this.MatchSignUpTable[i].id);
          }
        }
        // return
        this.$axios
          .post(
            '/event/user_sign', {
              sign_id: signArr
            }, {
              headers: {
                token: window.sessionStorage.getItem('token')
              }
            }
          )
          .then(res => {
            if (res.data.code == 200) {
              this.$store.dispatch('getTimeLine', this.$route.query.MatchId);
              this.$message({
                message: res.data.message,
                type: 'success'
              });
              let idObj = {};
              idObj.com_id = this.$route.query.MatchId;
              idObj.project_id = this.$route.query.teamId;
              this.signCount = res.data.data;
            } else {
              this.$message({
                message: res.data.message,
                type: 'error'
              });
            }
          });
      },
      Back: function() {
        this.$router.push({
          path: '/index/match/MatchDetail',
          query: {
            MatchId: this.$route.query.MatchId
          }
        });
      },
      limit() {
        let arr = [];
        if (this.MatchSign.one_limit) {
          arr.push(this.MatchSign.one_limit);
        }
        if (this.MatchSign.two_limit) {
          arr.push(this.MatchSign.two_limit);
        }
        if (this.MatchSign.three_limit) {
          arr.push(this.MatchSign.three_limit);
        }
        if (arr[0] == '省') {
          if (arr[1] == '市') {
            if (arr[2] == '区') {
              this.searchProvinceOptions = regionDataPlus;
            } else {
              this.searchProvinceOptions = provinceAndCityData;
            }
          } else {
            let provinceArr = JSON.parse(JSON.stringify(provinceAndCityData));
            for (let a in provinceArr) {
              delete provinceArr[a].children;
            }
            this.searchProvinceOptions = provinceArr;
          }
          this.showLimitInputs = false;
        }
        return arr;
      }
    }
  };
</script>

<style lang="less" scoped>
  [v-cloak] {
    display: none;
  }

  .basicInfo {
    background: linear-gradient(90deg, rgba(66, 185, 131, 0.2), rgba(66, 185, 131, 0.4));
    border-radius: 2px;
    line-height: 30px;
    height: 30px;
    padding: 15px;
    overflow: hidden;
    display: flex;
    justify-content: space-around;
    align-items: center;

    span {
      margin-right: 20px;
    }

    .btnGroup {
      /*height: 60px;*/
      /*float: right;*/
      margin-right: 20px;
    }

    .date {
      width: 25%;
      padding: 10px 15px;
    }
  }

  .MatchSignUp {
    width: 90%;
    margin-top: 20px;
    margin-left: 40px;
    display: flex;
    flex-direction: column;
  }

  .TopBar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    font-size: 15px;
    padding-bottom: 30px;
    border-bottom: 1px dashed #93c6fa;
  }

  .ContentSelect {
    display: flex;
    padding-left: 7%;
    justify-content: space-between;
  }

  .Team {
    display: flex;
    align-items: center;
    width: 300px;
  }

  .TeamName {
    width: 100px;
  }
</style>
